package com.lanhao.aot.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;

import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class DateUtil {
	public static XMLGregorianCalendar convertToXMLGregorianCalendar(Date date) {
		GregorianCalendar cal = new GregorianCalendar();
		cal.setTime(date);
		XMLGregorianCalendar gc = null;
		try {
			gc = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
		} catch (Exception e) {

			e.printStackTrace();
		}
		return gc;
	}
	
	
	public static XMLGregorianCalendar convertToXMLGregorianCalendar(String dateStr) {
		Date date = cn.hutool.core.date.DateUtil.parse(dateStr, "yyyy-MM-dd HH:mm:ss");
		XMLGregorianCalendar gc = convertToXMLGregorianCalendar(date);
		return gc;
	}
	
	public static void main(String[] args) {
		SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
		String format = sdf.format(new Date());
		System.out.println(format);
	}
}
